﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Configuration;
using System.Data.SqlClient;

/// <summary>
/// Summary description for ProductDA
/// </summary>
/// 
namespace Bestlife.ERP.DataAccess
{
    public class ProductDA
    {
        public ProductDA()
        {
            //
            // TODO: Add constructor logic here
            //
        }


        public static Bestlife.ERP.Entities.ProductE GetProuct(string pid,string code)
        {
            string pro_id=pid;
            string P_code=code;

         

            Bestlife.ERP.Entities.ProductE pE = new Entities.ProductE();

            
            try
            {
                String connStr = ConfigurationManager.ConnectionStrings["MainConnStr"].ConnectionString;
                Bestlife.ERP.DataAccess.clsCon.connect(connStr);

                String SelectProduct = "SELECT * from Tbl_Product p where p.Pro_ID='" + pro_id+"'and p.Code='"+P_code+"'";
                //SqlCommand act = new SqlCommand("UPDATE Bonus SET T_commision='" + tcom + "' WHERE User_id='" + id + "'", clsCon.conn_new);


                bool ExProduct = Bestlife.ERP.DataAccess.clsCon.AddEditDel(SelectProduct);

                SqlDataReader rdR;
                rdR = clsCon.ReadTable(SelectProduct);

                if (rdR.Read())
                {
                    pE.Product_ID = rdR["Pro_ID"].ToString();
                    pE.Code = rdR["Code"].ToString();
                    pE.Description = rdR["Description"].ToString();
                    pE.Pro_Name = rdR["Pro_Name"].ToString();
                    pE.Pro_Price = decimal.Parse(rdR["Pro_Price"].ToString());
                    pE.Ret_Price = decimal.Parse(rdR["Ret_Price"].ToString());
                    pE.Pur_Price = decimal.Parse(rdR["Pur_Price"].ToString());
                    pE.Point_Value = decimal.Parse(rdR["Point_Value"].ToString());
                    pE.Pro_Type = rdR["Pro_Type"].ToString();
                    pE.Pro_Image = rdR["Pro_Image"].ToString();
                    pE.Pro_Image1 = rdR["Pro_Image2"].ToString();
                    pE.Pro_Image2 = rdR["Pro_Image3"].ToString();
                    //pE.Pro_Image3 = rdR["Pro_Image4"].ToString();
                    pE.Cat_ID = rdR["Cat_ID"].ToString(); ;
                    pE.Sub_Cat = rdR["Sub_Cat"].ToString();
                    pE.Business_Value = decimal.Parse(rdR["Business_Value"].ToString());

                    rdR.Close();
                }
            }
            catch (Exception ex) { }
            return pE;
        }





    }
}